package chapter18;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;

public class SerializableA implements Serializable,Externalizable{

	private static final long serialVersionUID = 2553047350283557826L;
	private SerializableB ele;
	private String tag="SerializableA";
	
	
	public SerializableA(){}
	public SerializableA(SerializableB _ele)
	{
		ele=_ele;
	}
	
	public String toString()
	{
		return tag+"\t"+ele.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	@Override
	public void writeExternal(ObjectOutput out) throws IOException {
		// TODO Auto-generated method stub
		out.writeObject(ele);
		
	}

	@Override
	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		// TODO Auto-generated method stub
		ele=(SerializableB)in.readObject();
		
	}

}
